/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-01 22:19:07
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.service;

import java.util.List;
import java.util.Map;

import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.exception.ApiBusinessException;
import com.joysuch.wwyt.core.exception.BusinessRestrictionsException;
import com.joysuch.wwyt.edu.bean.*;
import com.joysuch.wwyt.edu.bean.EduDoExamResultBean.ExamResult;
import com.joysuch.wwyt.edu.bean.EduExamCenterListBean.AppSearchEduExamRecord;
import com.joysuch.wwyt.edu.bean.EduExamCenterListBean.SearchEduExamCenter;
import com.joysuch.wwyt.edu.bean.EduExamListBean.SearchEduExam;
import com.joysuch.wwyt.edu.entity.EduExam;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public interface EduExamService {

    public EduExam add(EduExamEditBean entity);

    void update(EduExamEditBean entity);

    Page<EduExamListBean> findByPage(Pageable page, SearchEduExam condition);

    void delete(Long id) throws BusinessRestrictionsException;

    EduExamDetailBean getById(Long id,Boolean isWeb);

    EduExam findById(Long id);

    /**
     * 更改考试发布状态。
     * 已经发布的考试，如果已经开始，则不可以进行取消
     *
     * @param id
     * @param state
     */
    public void changeState(Long id, Integer state) throws ApiBusinessException;

    Page<EduExamCenterListBean> queryUserExamCenterPage(Pageable page, Long userId, SearchEduExamCenter condition);

    ResultBean queryUserMarkingPapersCenterPage(Pageable page, Long userId, EduMarkingPapersCenterListBean.SearchEduMarkingPapersCenter params);
    /**
     * 校验课程是否学习完
     * @param userId 用户id
     * @param examId 考试id
     * @return 返回为学习完的课程
     */
    String checkCourseLearn(Long userId,Long examId);

    public EduDoExamBean loadExam(Long id, Long userId);

    /**
     *
     * @param result
     * @param currentUserId
     * @param isSubmit 是否自动提交 1是 0否
     * @return
     */
    ExamResult submit(EduDoExamResultBean result, Long currentUserId,Integer isSubmit);

    /**
     * 判断是否包含主观题
     * @param examId 考试id
     * @return
     */
    Boolean checkExamContainZgt(Long examId);

    /**
     * 查询给定用户列表参与考试的结果情况
     *
     * @param examId
     *                   考试ID
     * @param userIdList
     *                   用户ID列表
     * @return 考试情况统计
     */
    public EduExamUserRecordBean queryExamUserRecords(Long examId, List<Long> userIdList);

    public Page<EduExamCenterListBean> queryUserExamRecordPage(Pageable page, Long currentUserId,
            AppSearchEduExamRecord condition);

    ResultBean eduExamRelease();

    public List<EduTestPaperQuestionDetailBean> queryQuestionListByExamId(Long id, Integer showAnswer, Long userId, Long examRecordId);

    void submitMarkingPapers(List<EduDoExamResultBean.ExamUserAnswer> examUserAnswerList);

    /**
     * 查询考试信息
     * @param examId 考试id
     * @param userId 用户id
     * @param examRecordId 考试记录id
     * @param questionType 试题类型
     * @param isScore 是否打分 1 已打分 0 未打分
     * @return
     */
    List<EduTestPaperQuestionDetailBean> queryMarkingPapersList(Long examId, Long userId, Long examRecordId,String questionType, Integer isScore);

    /**
     *
     * @param result
     * @param currentUserId
     * @param handle 操作 1 新增  2 删除 3 获取
     * @return
     */
    String cacheAnswers(EduDoExamResultBean result, Long currentUserId,Integer handle);

    Object selectNoTrainningExam(SearchEduExam condition);

    void examExcel(Long examId, HttpServletRequest request, HttpServletResponse response);

    Map<String, Object> importExcel(Long examId, MultipartFile file);

    ResultBean myExamList(EduTrainningRecordListBean.SearchEduTrainningRecord condition);

    void initializedData();

    EduExamTypeBean getPaper(Long id);
}
